import Home from '../views/Home.vue'
import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
import SearchTakeout from '../views/SearchTakeout.vue'
import Takeout from '../views/Takeout.vue'
import Menu from '../components/Menu.vue'
import MyTakeouts from '../components/MyTakeouts.vue'
import AddTakeout from '../components/AddTakeout.vue'
import AdminApplyTakeout from '../components/AdminApplyTakeout.vue'
import Login from '../views/Login.vue'
import Register from '../views/Register.vue'
import Profile from '../views/Profile.vue'
import PersonalInfo from '../components/PersonalInfo.vue'
import MyOrder from '../components/MyOrder.vue'
import UpdateInfo from '../components/UpdateInfo.vue'
import MyAddress from '../components/MyAddress.vue'
import ApplyStore from '../components/ApplyStore.vue'
import AdminApplyStore from '../components/AdminApplyStore.vue'
import MyMessage from '../components/MyMessage.vue'
import MyStoreInfo from '../components/MyStoreInfo.vue'
import Order from '../views/Order.vue'
import Recharge from '../components/Recharge.vue'
import Pay from '../views/Pay.vue'
import Success from '../views/Success.vue'
// 管理员相关页面
import AdminLogin from '../views/admin/AdminLogin.vue'
import AdminLayout from '../views/admin/AdminLayout.vue'
import Dashboard from '../views/admin/Dashboard.vue'
import UserManage from '../views/admin/UserManage.vue'
import StoreManage from '../views/admin/StoreManage.vue'
import TakeoutManage from '../views/admin/TakeoutManage.vue'
import OrderManage from '../views/admin/OrderManage.vue'
import Statistics from '../views/admin/Statistics.vue'

const routes: Array<RouteRecordRaw> = [
    {
        path: '/',
        name: 'Home',
        component: Home
    }, {
        path: '/login',
        name: 'Login',
        component: Login
    }, {
        path: '/register',
        name: 'Register',
        component: Register
    }, {
        path: '/search',
        name: 'Search',
        component: SearchTakeout
    }, {
        path: '/takeout',
        name: 'Takeout',
        component: Takeout
    },
    {
        path: '/pay',
        name: 'Pay',
        component: Pay
    }, {
        path: '/success',
        name: 'Success',
        component: Success
    },
    {
        path: '/order',
        name: 'Order',
        component: Order
    },
    {
        path: '/profile',
        name: 'Profile',
        component: Profile,
        meta: { KeepAlive: true },
        children: [
            {
                path: '/personalinfo',
                name: 'PersonalInfo',
                component: PersonalInfo
            }, {
                path: '/myorder',
                name: 'MyOrder',
                component: MyOrder
            }, {
                path: '/menu',
                name: 'Menu',
                component: Menu
            }, {
                path: '/mytakeouts',
                name: 'MyTakeouts',
                component: MyTakeouts
            }, {
                path: '/addtakeout',
                name: 'AddTakeout',
                component: AddTakeout
            }, {
                path: '/updateinfo',
                name: 'UpdateInfo',
                component: UpdateInfo
            }, {
                path: '/myaddress',
                name: 'MyAddress',
                component: MyAddress
            }, {
                path: '/applystore',
                name: 'ApplyStore',
                component: ApplyStore
            }, {
                path: '/adminapplystore',
                name: 'AdminApplyStore',
                component: AdminApplyStore
            }, {
                path: '/adminapplytakeout',
                name: 'AdminApplyTakeout',
                component: AdminApplyTakeout
            }, {
                path: '/mymessages',
                name: 'MyMessages',
                component: MyMessage
            }, {
                path: '/myStore',
                name: 'MyStore',
                component: MyStoreInfo
            }, {
                path: '/recharge',
                name: 'Recharge',
                component: Recharge
            }
        ]
    },
    // 管理员相关路由
    {
        path: '/admin/login',
        name: 'AdminLogin',
        component: AdminLogin
    },
    {
        path: '/admin',
        name: 'AdminLayout',
        component: AdminLayout,
        redirect: '/admin/dashboard',
        children: [
            {
                path: 'dashboard',
                name: 'AdminDashboard',
                component: Dashboard
            },
            {
                path: 'users',
                name: 'AdminUsers',
                component: UserManage
            },
            {
                path: 'stores',
                name: 'AdminStores',
                component: StoreManage
            },
            {
                path: 'takeouts',
                name: 'AdminTakeouts',
                component: TakeoutManage
            },
            {
                path: 'orders',
                name: 'AdminOrders',
                component: OrderManage
            },
            {
                path: 'statistics',
                name: 'AdminStatistics',
                component: Statistics
            }
        ]
    }
]
const router = createRouter({
    history: createWebHashHistory(process.env.BASE_URL),
    routes
})

export default router;
